<template>
  <div class="table">
    <hb-grid-input v-bind:vlistCode="vlistCode"></hb-grid-input>
    <!-- <upload-table v-bind:raid="smsNo"
      v-bind:linkTableType="linkTableType"
      v-bind:rnucode="rnucode"></upload-table>
    <grid v-bind:cloumns="cloumns"></grid> -->
    <!-- <fileupload v-bind:tableSetJson="tableSetJson"
    v-bind:renumin="renumdatein"
    v-bind:linkTableType="linkTableType"></fileupload>

    <imgupload v-bind:tableSetJson="tableSetJson"
    v-bind:renumin="renumdatein"
    v-bind:linkTableType="linkTableType"></imgupload>

    <multipoints v-bind:tableSetJson="tableSetJson"
    v-bind:renumin="renumdatein"></multipoints> -->
    <!-- <el-button @click="changeData()">触发事件</el-button> -->
            
            <!-- <el-button @click="changeVlistCode">改变vlistCode的值</el-button> -->
  </div>
</template>
<script>
import tableheder1 from "../../components/report/tableheader1.vue";
import stringinput from "../../components/report/stringinput.vue";
import dateinput from "../../components/report/dateinput.vue";
import numinput from "../../components/report/numinput.vue";
import qualifiledradio from "../../components/report/qualifiledradio.vue";
import dropdown from "../../components/report/dropdown.vue";
import flowrecord from "../../components/report/flowrecord.vue";
import multipoints from "../../components/report/multipoints.vue";
import imgupload from "../../components/report/imgupload.vue";
import fileupload from "../../components/report/fileupload.vue";
import grid from "../../components/report/grid.vue";
import gridInput from "../../components/input/gridInput.vue";
import treeInput from "../../components/input/treeInput.vue";
import uploadTable from "../../components/security/uploadTable.vue";
import selectComponent from "../../components/selectComponent/selectComponent.vue";
import hbGridInput from "../../components/input/hbGridInput.vue";

import checklist from "@/assets/data.json";
import { queryRecordById_Url,uploadFile_Url,executionSql } from "@/config/api";
export default {
  name: "Zjtest",
  components: {
    tableheder1,
    stringinput,
    dateinput,
    numinput,
    qualifiledradio,
    dropdown,
    flowrecord,
    multipoints,
    imgupload,
    fileupload,
    gridInput,
    treeInput,
    selectComponent,
    grid,
    uploadTable,
    hbGridInput
  },
  data() {
    return {

      //upload-table组件
      smsNo: "",
      linkTableType: "3",
      rnucode: "",

      //grid组件
      cloumns:[
        { id: "equiment", cloumnDesc: "设备", type: "" },
        { id: "eqrule", cloumnDesc: "设计标准", type: "" },
        { id: "muli", cloumnDesc: "测试值", type: "" },
        { id: "result", cloumnDesc: "测试结果", type: "" }
      ],


      //
      vlistCode: "queryMenu",
      queryMap: {
      },
      // vlistEntity: {
      //   vlistId: "6fdfd4f4cefa43a48cd7e27f292a9b20",
      //   vlistCode: "ccc",
      //   vlistName: "反弹",
      //   menuCode: "ccc",
      //   tableCode: "ccc",
      //   vlistType: "0",
      //   vlistMode: "1",
      //   outputMode: "1",
      //   outKey: "",
      //   outDescription: "",
      //   vlistRemark: "",
      //   vlistKey: "ccc",
      //   vlistKeyDesc: "ccc菜单",
      //   vlistSql: "select * from sm_menu where MENU_NAME like '%@menuName%'"
      // },
      text: "",
      tableJson: [],
      tableSetJson: {"type":"multipoints","orderno":"bpsyt","name":"bpsyt","label":"钻孔布置、装药及爆破顺序示意图","texttip":"示意图：见附图","labeltip":"","designValue":"10","compareValue":"2","compareSymbol":"lt","hasdetail":false},
      recordin: {
        raplace: "1111", //施工部位
        raverdict: "222", //检查内容
        rastandard: "", //检测标准
        radraw: "", //施工图号
        rasdate: "", //施工开始时间
        raedate: "", //施工结束时间
        rains: "" //检测仪器
      },
      renumdatein: {
        rnId: "",
        raId: "393aee46bb0f4fd08145c372a0540258",
        rnuRaid: "",
        rnuCode: "bpsyt", //验评指标明细编号
        rnuType: "", //检测项编辑类型
        rnuContent: "", //检测值验评内容
        rnuRadioContent: "", //检测指标状态验评内容
        rsDes: "", //描述（大字段）
        rnuContent1: "0", //检测指标验评内容扩展字段1
        rnuContent2: "0", //检测指标验评内容扩展字段2
        rnuRadioContent1: "0/0", //验评指标状态验评扩展内容1
        rnuRadioContent2: "", //验评指标状态验评扩展内容1
        rnuNo: "", //序号
        zlRecordNumDetails: []
      },
      // linkTableType: "2",
      fillInListBodyData: {},
      detailObject: {},
      detailList: [],
      imgList: [], //已上传的图片集合
    };
  },
  activated() {
    this.tableJson = checklist;
    // this.tableSetJson = this.tableJson[0].detail[0].detail[0];
    // this.getDetailList();
    // console.log("============>>>>>>" + JSON.stringify(this.tableSetJson));
  },
  methods: {
    getImageList(files) {
      this.$nextTick(() => {
        for (let i = 0, len = files.length; i < len; i++) {
          this.imgList.push(files[i].src.split("base64,")[1]);
          //上传图片
          //   this._getFileCode({
          //     Base64Str: files[i].src.split("base64,")[1],
          //     AttachmentType: this.$enums.AttachmentType.Activity
          //   });
        }
      });
    },
    //删除图片
    removeImage(index) {
      this.imgList.splice(index, 1);
    },
    getFileList() {
      executionSql({
        executionSql:"ZL_DOCUMENTFILES",
        docRelId:"393aee46bb0f4fd08145c372a0540258"
      }).then(res => {
        
      });
    },
    getDetailList() {
      for (var index in this.tableJson) {
        for (var indexd in this.tableJson[index].detail) {
          this.fillInListBodyData[this.tableJson[index].detail[indexd].name] = {
            rnId: "",
            raId: "",
            rnuRaid: "",
            rnuCode: "", //验评指标明细编号
            rnuType: "", //检测项编辑类型
            rnuContent: "", //检测值验评内容
            rnuRadioContent: "", //检测指标状态验评内容
            rsDes: "", //描述（大字段）
            rnuContent1: "", //检测指标验评内容扩展字段1
            rnuContent2: "", //检测指标验评内容扩展字段2
            rnuRadioContent1: "", //验评指标状态验评扩展内容1
            rnuRadioContent2: "", //验评指标状态验评扩展内容1
            rnuNo: "", //序号
            zlRecordNumDetails: []
          };
          for (var indexdd in this.tableJson[index].detail[indexd].detail) {
            this.fillInListBodyData[
              this.tableJson[index].detail[indexd].detail[indexdd].name
            ] = {
              rnId: "",
              raId: "",
              rnuRaid: "",
              rnuCode: "", //验评指标明细编号
              rnuType: "", //检测项编辑类型
              rnuContent: "", //检测值验评内容
              rnuRadioContent: "", //检测指标状态验评内容
              rsDes: "", //描述（大字段）
              rnuContent1: "", //检测指标验评内容扩展字段1
              rnuContent2: "", //检测指标验评内容扩展字段2
              rnuRadioContent1: "", //验评指标状态验评扩展内容1
              rnuRadioContent2: "", //验评指标状态验评扩展内容1
              rnuNo: "", //序号
              zlRecordNumDetails: []
            };
          }
        }
      }
      console.log("fillIn====>>>>" + JSON.stringify(this.fillInListBodyData));
    },
    getCheckListDataByRaId() {
      queryRecordById_Url({
        RAID: "29108afb87f74d2e91548e6d3e652648"
      }).then(res => {
        this.isflag = 1;
        console.log(
          "根据raIde获取的填报内容为======>>>：" + JSON.stringify(res)
        );
        if (res.success) {
          /*已提交的填报详细信息*/
          var checkListData = [];
          checkListData = res.data;
          for (var index in checkListData) {
            this.fillInListBodyData = checkListData[index].detailList;
          }
        }
      });
    },
    getStringInputData(data) {
      console.log("stringinput传入的值====>>>" + JSON.stringify(data));
    },
    getTableHeader1(data) {
      console.log("tableheder1传入的值====>>>" + JSON.stringify(data));
    },
    getDateInputData(data) {
      console.log("dateinput传入的值====>>>" + JSON.stringify(data));
    },
    getNumInputData(data) {
      console.log("numinput传入的值====>>>" + JSON.stringify(data));
    },
    getRadioValue(data) {
      console.log("radio传入的值====>>>" + JSON.stringify(data));
    },
    getSelectValue(data) {
      console.log("select传入的值====>>>" + JSON.stringify(data));
    },
    getMultipointsValue(data) {
      console.log("multipoints传入的值====>>>" + JSON.stringify(data));
    },
    getImgUploadValue(data) {
      console.log("imgUpload传入的值====>>>" + JSON.stringify(data));
    },
    getGridInput(data) {
      console.log("gridInput传入的值====>>>" + JSON.stringify(data));
    },
    getdata(name) {
      // var renum = {
      //   rnId: "",
      //   raId: "",
      //   rnuRaid: "",
      //   rnuCode: "", //验评指标明细编号
      //   rnuType: "", //检测项编辑类型
      //   rnuContent: "", //检测值验评内容
      //   rnuRadioContent: "", //检测指标状态验评内容
      //   rsDes: "", //描述（大字段）
      //   rnuContent1: "", //检测指标验评内容扩展字段1
      //   rnuContent2: "", //检测指标验评内容扩展字段2
      //   rnuRadioContent1: "", //验评指标状态验评扩展内容1
      //   rnuRadioContent2: "", //验评指标状态验评扩展内容1
      //   rnuNo: "", //序号
      //   zlRecordNumDetails: []
      // };
      // return renum.rnuRadioContent;
      if (
        this.fillInListBodyData[name] == null ||
        this.fillInListBodyData[name] == ""
      ) {
        var renum = {
          rnId: "",
          raId: "",
          rnuRaid: "",
          rnuCode: "", //验评指标明细编号
          rnuType: "", //检测项编辑类型
          rnuContent: "", //检测值验评内容
          rnuRadioContent: "", //检测指标状态验评内容
          rsDes: "", //描述（大字段）
          rnuContent1: "", //检测指标验评内容扩展字段1
          rnuContent2: "", //检测指标验评内容扩展字段2
          rnuRadioContent1: "", //验评指标状态验评扩展内容1
          rnuRadioContent2: "", //验评指标状态验评扩展内容1
          rnuNo: "", //序号
          zlRecordNumDetails: [],
          fileDes:[]
        };
        return renum.rnuRadioContent;
      } else {
        return this.fillInListBodyData[name];
      }
    },
    /* 获取子组件传递给父组件的数字数据 */
    childOuter(event, i) {
      console.log("event[" + i + "]===>" + JSON.stringify(event));
      console.log(
        "子组件传递给父组件的输入框输入的内容：=======>>>" +
          event.rnuRadioContent
      );
      this.detailObject[i] = event;
    },
    submit() {
      
      let fromdata = new FormData();
      this.renumdatein.fileDes.forEach(function (file) {
        fromdata.append("files", file.raw, file.name);
      });
      // 关联表的id
      fromdata.append("raid", "9c3cada2df504961b97e621559cf1847");
      fromdata.append("linkTableType", "2");
      console.log("提交的表单数据=====>>>>>>>" + fromdata);
      // fromdata.append("file[]",this.renumdatein.rsDes);
      uploadFile_Url(fromdata).then(res => {
         console.log("填报提交之后返回的状态=====>>>>>" + JSON.stringify(res));
        if (res.data.success) {
          this.$message.success("填报数据保存成功！");
        } else {
          this.$message.error("添加数据失败！");
        }
        this.disabled = false;
      });
    }
  }
};
</script>
<style>
.handle-box1 {
  margin-bottom: 10px;
  background-color: #ffffff;
  height: 130px;
  border-radius: 10px;
}
.firstClass {
  border: 1px solid #c5c5c5;
  margin-top: 5px;
  width: 748px;
}
.secondClass {
  border: 1px solid #c5c5c5;
  margin-left: 5px;
  margin-top: 5px;
  margin-bottom: 5px;
  width: 736px;
}
.thirdClass {
  border: 1px solid #c5c5c5;
  margin-left: 5px;
  margin-top: 5px;
  margin-bottom: 5px;
}
.contentdiv {
  background-color: rgba(0, 0, 0, 0.04);
  width: 750px;
  margin: 0 auto;
}
</style>

